package com.ruoyi.restaurant.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.restaurant.domain.SysTable;
import com.ruoyi.restaurant.service.ISysTableService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 餐台管理Controller
 * 
 * @author ruoyi
 * @date 2022-04-12
 */
@RestController
@RequestMapping("/table/show")
public class SysTableController extends BaseController
{
    @Autowired
    private ISysTableService sysTableService;

    /**
     * 查询餐台管理列表
     */
    @PreAuthorize("@ss.hasPermi('table:show:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysTable sysTable)
    {
        startPage();
        List<SysTable> list = sysTableService.selectSysTableList(sysTable);
        return getDataTable(list);
    }

    /**
     * 导出餐台管理列表
     */
    @PreAuthorize("@ss.hasPermi('table:show:export')")
    @Log(title = "餐台管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysTable sysTable)
    {
        List<SysTable> list = sysTableService.selectSysTableList(sysTable);
        ExcelUtil<SysTable> util = new ExcelUtil<SysTable>(SysTable.class);
        util.exportExcel(response, list, "餐台管理数据");
    }

    /**
     * 获取餐台管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('table:show:query')")
    @GetMapping(value = "/{tableId}")
    public AjaxResult getInfo(@PathVariable("tableId") Integer tableId)
    {
        return AjaxResult.success(sysTableService.selectSysTableByTableId(tableId));
    }

    /**
     * 新增餐台管理
     */
    @PreAuthorize("@ss.hasPermi('table:show:add')")
    @Log(title = "餐台管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysTable sysTable)
    {
        return toAjax(sysTableService.insertSysTable(sysTable));
    }

    /**
     * 修改餐台管理
     */
    @PreAuthorize("@ss.hasPermi('table:show:edit')")
    @Log(title = "餐台管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysTable sysTable)
    {
        return toAjax(sysTableService.updateSysTable(sysTable));
    }

    /**
     * 删除餐台管理
     */
    @PreAuthorize("@ss.hasPermi('table:show:remove')")
    @Log(title = "餐台管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tableIds}")
    public AjaxResult remove(@PathVariable Integer[] tableIds)
    {
        return toAjax(sysTableService.deleteSysTableByTableIds(tableIds));
    }
}
